package com.esreport.dao;

import com.esreport.entity.Statistics;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

/**
 * @ClassName StatisticsRepository
 * @Description
 * @Author fanxingwei
 * @Date 2020/8/25 16:52
 * @Version 1.0
 */
@Repository
public interface StatisticsRepository extends JpaRepository<Statistics,Integer>,JpaSpecificationExecutor<Statistics> {

    List<Statistics> findBySiteIdOrderByDateDesc(Integer siteId);

    @Query("select count(id) from Statistics where date = :date and siteId = :siteId")
    Integer getNum(@Param("date")Date date,@Param("siteId")Integer siteId);


    Statistics getBySiteId(Integer siteId);

}
